package toutiao.t3;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.Scanner;

/**
 * 5 5 3
 aaa aaaaaaa aaaaa
 a a a a a
 a a a a a
 a a a a a
 a a a a a
 a a a a a
 */
public class Main {

    static final int[][] dirct = {{0,1},{0,-1},{1,0},{-1,0}};

    static HashSet<Point> used = new HashSet<>();

    static int M;
    static int N;

    static ArrayList<String> res = new ArrayList<>();
    static boolean resFlag = false;

    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);
        M = scanner.nextInt();
        N = scanner.nextInt();
        int K = scanner.nextInt();
        String[][] dirction = new String[N][M];
        String[] words = new String[K];
        for(int i=0;i<K;i++){
            words[i] = scanner.next();
        }
        for(int i=0;i<N;i++){
            for(int j=0;j<M;j++){
                dirction[i][j] = scanner.next();
            }
        }

        for(String w: words) {
            if(M*N < w.length()){
                continue;
            }
            used.clear();
            m:
            for (int i = 0; i < N; i++) {
                for (int j = 0; j < M; j++) {
//                    System.out.println(i+" "+j+" "+w);
                    if (dirction[i][j].equals(w.substring(0,1))){
                        Point s = new Point(i, j);
                        used.add(s);
                        dfs(s, w, 1, dirction);
                        used.remove(s);
                        if(resFlag){
                            resFlag = false;
                            break m;
                        }
                    }
                }
            }
        }
        for(String r: res){
            System.out.println(r);
        }

    }

    public static void dfs(Point p, String target, int ind, String[][] direction){

//        System.out.println(p+" "+ind+" "+target.length());

        if(resFlag){
            return;
        }

        if(target.length() == ind){
            res.add(target);
            resFlag = true;
            return;
        }

        for(int i=0;i<4;i++){
            Point newP = new Point(p.x+dirct[i][0], p.y+dirct[i][1]);
            if(judge(newP) && !used.contains(newP) && target.substring(ind, ind+1).equals(direction[newP.x][newP.y])){
                used.add(newP);
                dfs(newP, target, ind+1, direction);
                used.remove(newP);
            }
        }

    }

    public static boolean judge(Point p){
        if(p.x<0 || p.x>=N || p.y<0 || p.y>=M)
            return false;
        return true;
    }

}

class Point{
    int x;
    int y;

    public Point(int x, int y) {
        this.x = x;
        this.y = y;
    }

    @Override
    public String toString() {
        return "Point{" +
                "x=" + x +
                ", y=" + y +
                '}';
    }
}